﻿Public Class SearchUsersForm
    Dim dt As DataTable
    Public selected_user As User
    Private Sub ChiPhiForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        dt = UsersDAO.GetAll()
        dgUser.DataSource = dt
        dgUser.Columns(1).HeaderText = "Tên đầy đủ"
        dgUser.Columns(2).HeaderText = "Tên người dùng"
        dgUser.Columns(0).Visible = False
        dgUser.Columns("QuyenHan").Visible = False
    End Sub

    Private Sub btExit_Click(sender As System.Object, e As System.EventArgs) Handles btExit.Click
        Me.Hide()
    End Sub
    Private Sub dgUser_CellClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgUser.CellClick
        Dim u As New User
        u.MaUser = Integer.Parse(dgUser.CurrentRow.Cells("MaUser").Value)
        u.Fullname = dgUser.CurrentRow.Cells("Fullname").Value.ToString()
        Me.selected_user = u
        Me.DialogResult = DialogResult.OK
    End Sub

    Private Sub txtFullname_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtFullname.TextChanged
        Dim filter As String = String.Format("fullname like '%{0}%'", txtFullname.Text)
        dt.DefaultView.RowFilter = filter
    End Sub

    Private Sub btnTatCa_Click(sender As System.Object, e As System.EventArgs) Handles btnTatCa.Click
        dt.DefaultView.RowFilter = ""
    End Sub
End Class